//
//  LMwebVIewController.m
//  彩票
//
//  Created by 张青花 on 15/9/28.
//  Copyright (c) 2015年 李明. All rights reserved.
//

#import "LMwebVIewController.h"

@interface LMwebVIewController () <UIWebViewDelegate>

@property (nonatomic,weak)UIWebView *webview;
@end

@implementation LMwebVIewController

-(void)loadView
{
    UIWebView *webview = [[UIWebView alloc] init];
    webview.delegate = self;
    self.view = webview;
    self.webview = webview;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"测试";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(btnClick)];
    
//    NSURL *url = [[NSURL alloc] initWithString:@"http://www.baidu.com"];
    NSURL *url = [[NSBundle mainBundle] URLForResource:self.htmlPage.html withExtension:nil];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
    
    [self.webview loadRequest:request];

}

-(void)btnClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}


- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    if (self.htmlPage.ID==nil) {
        return;
    }
    
    NSString *jsStr =[NSString stringWithFormat:@" window.location.href='#%@'",self.htmlPage.ID];
    
    [webView stringByEvaluatingJavaScriptFromString:jsStr];
}
@end
